﻿using EntityModels.DbContexts;


namespace EntityModels.Normal
{
    /// <summary>
    /// 数据种子
    /// </summary>
    public class UseDataSeeding
    {
        void MyMethod()
        {
            using (var context = new DataSeedingContext())
            {
                context.Database.EnsureCreated();

                var entity = context.DataSeedingEntities.FirstOrDefault(b => b.Text == "Text");
                if (entity == null)
                {
                    context.DataSeedingEntities.Add(new Entities.DataSeedingEntity { Text = "Text" });
                }
                context.SaveChanges();
            }
        }
    }
}
